/*
 * Copyright (c) 2019-2020, https://api.iot.10086.cn/(https://gitee.com/cmcc-iot-api/iot-card-open-application/).
 */
package cn.iot.card.open.ec.controller;

import cn.iot.card.open.ec.service.EcSmartVoiceService;
import cn.iot.card.open.pojo.page.LayuiPageFactory;
import cn.iot.card.open.util.CommonUtil;
import cn.stylefeng.roses.core.base.controller.BaseController;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.io.IOException;
import java.util.Map;

/**
 * 集团智能网语音信息
 *
 * @author cmcc-iot-api
 * @date 20191230 09:54:12
 */
@Controller
@RequestMapping("/smartVoice")
public class EcSmartVoiceController extends BaseController {

    /**
     * 集团智能网语音信息页面路径前缀
     */
    private static String PREFIX_PAGE = "/modular/ec/smartVoice/";

    @Autowired
    private EcSmartVoiceService ecSmartVoiceService;

    /**
     * 跳转到集团智能网语音列表的页面
     *
     * @return 返回
     * @author cmcc-iot-api
     * @date 20191230 11:41:07
     */
    @RequestMapping("")
    public String index() {
        return PREFIX_PAGE + "smartVoice.html";
    }

    /**
     * 查询 集团智能网语音列表
     * @param accountId 集团id
     * @return
     * @throws IOException
     */
    @RequestMapping("/list")
    @ResponseBody
    public Object list(@RequestParam(required = false) String accountId) throws IOException {
        String transId = CommonUtil.generateTransId(accountId);
        return ecSmartVoiceService.selectEcSmartVoice(transId, accountId);
    }

    /**
     * 跳转到查看企业客户成员通话参数页面
     *
     * @param callParam 企业客户成员通话参数
     * @param model
     * @return
     */
    @RequestMapping("/callParam")
    public String callParam(@RequestParam String callParam, Model model) {
        model.addAttribute("callParam", callParam);
        return PREFIX_PAGE + "smartVoice_callParamList.html";
    }

    /**
     * 获取企业客户成员通话参数列表
     *
     * @param callParam 企业客户成员通话参数
     * @return
     */
    @RequestMapping("/callParamList")
    @ResponseBody
    public Object callParamList(@RequestParam String callParam) {
        Page<Map<String, Object>> callParamList = ecSmartVoiceService.getCallParamList(callParam);
        return LayuiPageFactory.createPageInfo(callParamList);
    }

}
